package org.radar.os;

import java.util.Locale;

/**
 * 操作系统相关信息工具类
 *
 * @author zhangcs
 * @since 1.0
 */
public class OSUtils {

    /**
     * 操作系统名称
     */
    private static final String OPERATING_SYSTEM_NAME = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);

    /**
     * 当前系统平台
     */
    private static final PlatformEnum platform;

    static {
        if (OPERATING_SYSTEM_NAME.startsWith("linux")) {
            platform = PlatformEnum.LINUX;
        } else if (OPERATING_SYSTEM_NAME.startsWith("mac") || OPERATING_SYSTEM_NAME.startsWith("darwin")) {
            platform = PlatformEnum.MACOS;
        } else if (OPERATING_SYSTEM_NAME.startsWith("windows")) {
            platform = PlatformEnum.WINDOWS;
        } else {
            platform = PlatformEnum.OTHER;
        }
    }

    /**
     * 获取当前系统平台
     *
     * @return 返回系统平台枚举对象
     */
    public static PlatformEnum getPlatform() {
        return OSUtils.platform;
    }
}
